<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改用户</title>
    <link href="{{ url_for('static', filename = 'css/bootstrap.min.css') }}" rel="stylesheet">
    <style>
      body {
        padding-top: 30px;
        background-color: #f8f9fa;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      }
      .form-container {
        max-width: 500px;
        margin: 0 auto;
      }
      .card {
        border: none;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
      }
      .card-header {
        background-color: #4a6fa5;
        color: white;
        border-radius: 10px 10px 0 0 !important;
        padding: 12px 20px;
        font-size: 1.1rem;
        font-weight: 500;
      }
      .card-body {
        padding: 18px 20px;
      }
      .form-group {
        margin-bottom: 15px;
      }
      label {
        font-weight: 500;
        margin-bottom: 5px;
        color: #495057;
      }
      .form-control {
        border-radius: 6px;
        border: 1px solid #e2e8f0;
        padding: 6px 12px;
        height: 36px;
        transition: border-color 0.2s, box-shadow 0.2s;
      }
      .form-control:focus {
        border-color: #4a6fa5;
        box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
        outline: none;
      }
      .form-check {
        padding-left: 15%
      }
      .form-check-input {
        margin-right: 6px;
      }
      .gender-radio {
        display: flex;
        gap: 15px;
      }
      .btn {
        border-radius: 6px;
        padding: 6px 14px;
        font-weight: 500;
        transition: all 0.2s ease;
      }
      .btn-primary {
        background-color: #4a6fa5;
        border-color: #4a6fa5;
      }
      .btn-primary:hover {
        background-color: #3d5c8a;
        border-color: #3d5c8a;
      }
      .btn-secondary {
        background-color: #6c757d;
        border-color: #6c757d;
      }
      .btn-secondary:hover {
        background-color: #5a6268;
        border-color: #545b62;
      }
      .alert {
        margin: 10px 0;
        padding: 10px;
        border-radius: 6px;
        font-size: 0.9rem;
      }
    </style>
  </head>
  <body>
    <div class="form-container">
      <div class="card">
        <div class="card-header">
          修改用户
        </div>
        <div class="card-body">
          <form action="/edit" method="post">
            {% if item %}
            <input type="hidden" name="id" value="{{item.id}}">

            <!-- 姓名输入框 -->
            <div class="form-group">
              <label for="name">姓名</label>
              <input type="text" class="form-control" id="name" name="name" value="{{item.name}}" required>
            </div>

            <!-- 年龄输入框 -->
            <div class="form-group">
              <label for="age">年龄</label>
              <input type="text" class="form-control" id="age" name="age" value="{{item.age}}" required>
            </div>

            <!-- 性别选择 -->
            <div class="form-group">
              <label>性别</label>
              <div class="gender-radio">
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="gender" id="gender01" value="男" {% if item.gender=="男" %} checked {% endif %}>
                  <label class="form-check-label" for="gender01">男</label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="gender" id="gender02" value="女" {% if item.gender=="女" %} checked {% endif %}>
                  <label class="form-check-label" for="gender02">女</label>
                </div>
              </div>
            </div>

            <!-- 联系电话输入框 -->
            <div class="form-group">
              <label for="phone">联系电话</label>
              <input type="text" class="form-control" id="phone" name="phone" value="{{item.phone}}" required>
            </div>

            <!-- 按钮区域 -->
            <div class="form-group mt-3 text-center">
              <button type="button" class="btn btn-secondary me-2" onclick="window.location.href='/'" style="min-width: 90px;">
                取消
              </button>
              <button type="submit" class="btn btn-primary" style="min-width: 90px;">
                保存
              </button>
            </div>

            {% endif %}
          </form>
        </div>
      </div>

      <!-- 提示信息 -->
      {% if success %}
      <div class="alert alert-warning mx-4 mb-3" role="alert">
        {{ success }}
      </div>
      {% endif %}
    </div>
  </body>
</html>